//
//  DMNavigationController.m
//  DistributionMallApp
//
//  Created by JHnoplan on 2018/10/18.
//  Copyright © 2018年 JHnoplan. All rights reserved.
//

#import "DMNavigationController.h"

@interface DMNavigationController ()

@end

@implementation DMNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"statusbar"] forBarMetrics:UIBarMetricsDefault];
//    self.navigationBar.layer.masksToBounds = YES;
    [self setNavigationBarTitleColor:[UIColor whiteColor]];


}

//设置导航栏文字颜色
-(void)setNavigationBarTitleColor:(UIColor *)color{
    
    UIFont *font = [UIFont systemFontOfSize:20];
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    [dict setObject:color forKey:NSForegroundColorAttributeName];
    [dict setObject:font forKey:NSFontAttributeName];
    UINavigationBar *bar = [UINavigationBar appearance];
    bar.titleTextAttributes = dict;
}



#pragma mark -推出另外一个控制器的逻辑控制
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.childViewControllers.count > 0) {
        // 设置返回按钮
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageWithRenderingOriginalName:@"top_back"] style:UIBarButtonItemStylePlain target:self action:@selector(cmdBack)];
        //自动隐藏tabbar
        [viewController setHidesBottomBarWhenPushed:YES];
    }
    
    [super pushViewController:viewController animated:animated];
}

-(void)cmdBack
{
    [self popViewControllerAnimated:YES];
}


@end
